Changing Atttribute access rights

Can anyone help a newbie DXL coder with setting the access rights to an attribute value.

I am trying to write some code that replaces the existing access rights to an attribute value with a new definition. This code will allow me to bring modules that have a variety of definitions up to a common standard.

The problem I am having is clearing out the existing definitions. I have tried using the unsetAllVal function but this has a habit of setting the access to read for everyone and hence I can not make any further changes.

My thoughts were to create an array which contains the users who currently have access and then use this to delete all the ones I don't use as shown in the code below. Unfortunately the code produced crashes.

string sGroups[i]
i=0
for ar in values ad do {
sGroups[i] = (username ar)
i++
}

//clear permissions for all except DOORS Admin

for (i=0; i < sizeof sGroups; i++) {
if (sGroups[i] != "DOORS Administrators") {
ErrMess unsetVal(m, ad, sGroups[i])
print "ErrMess = " "\n"
}
}
Any suggestions would be appreciated.

Pete
Peterb4134 - Thu May 20 07:34:25 EDT 2010

Re: Changing Atttribute access rights
llandale - Thu May 20 16:47:50 EDT 2010

You are getting crashes since you must, in DXL, declare your arrays at the full size at definition time: string sGroups[i], well 'i' might not be big enough.

Understand there are 3 flavors of 'attribute access': [1] Attr Types access lets you modify attr types [2] Attr Values lets you decide who can or cannot modify obj-attr values [3] Attr Definition rights lets you decide who can delete or modify an Attribute definition, such as changing the spelling or deciding it no longer logs History. Module access rights decides who can create attributes.

Guess I've never really thought about this. So here goes.

Lets talk about Attr Defintion rights, and presume we give access to groups, not to specific users.
o  If the attr access is Specific then set it to Inherited:
    AttrDef ad = find(mod, NameAttrDef)
        isAccessInheritied(ad, IsInherit)
        if (!IsInherit) inherited(ad)
o  Set it to Specific
        specific(ad)
o  Provide yourself full access
        setDef(mod, ad, read | modify | create | delete | control, doorsname())
o  Remove all the others.  Stage in a Skip, then delete
        AccessRec ar
        Skip skpARs = createString()
        for ar in ad do
        {  NameUser = username(ar)
           if (NameUser == doorsname()) continue   // Its me, don't delete
           put(skpARs, NameUser, ar)
        }
                // now delete
        for ar in skpARs do
        {  NameUser = (string key skpARs)
           unsetDef(mod, ar, NameUser)
        }
        delete(skpARs)
o  OK.  Specific Access, I have the only access rec.  Now add the ones I want
        For every desired access rec
        {  NameUser = desired Group Name
           Permission ps = desired Permission
           setDef(mod, ad, ps, NameUser)
        }
o  Delete the AR associated with me
        unsetDef(mod, ar, doorsname())


Good luck.

 

 

  • Louie

 

 

Re: Changing Atttribute access rights
a_vestlin - Fri May 21 03:13:14 EDT 2010

llandale - Thu May 20 16:47:50 EDT 2010

You are getting crashes since you must, in DXL, declare your arrays at the full size at definition time: string sGroups[i], well 'i' might not be big enough.

Understand there are 3 flavors of 'attribute access': [1] Attr Types access lets you modify attr types [2] Attr Values lets you decide who can or cannot modify obj-attr values [3] Attr Definition rights lets you decide who can delete or modify an Attribute definition, such as changing the spelling or deciding it no longer logs History. Module access rights decides who can create attributes.

Guess I've never really thought about this. So here goes.

Lets talk about Attr Defintion rights, and presume we give access to groups, not to specific users.
o  If the attr access is Specific then set it to Inherited:
    AttrDef ad = find(mod, NameAttrDef)
        isAccessInheritied(ad, IsInherit)
        if (!IsInherit) inherited(ad)
o  Set it to Specific
        specific(ad)
o  Provide yourself full access
        setDef(mod, ad, read | modify | create | delete | control, doorsname())
o  Remove all the others.  Stage in a Skip, then delete
        AccessRec ar
        Skip skpARs = createString()
        for ar in ad do
        {  NameUser = username(ar)
           if (NameUser == doorsname()) continue   // Its me, don't delete
           put(skpARs, NameUser, ar)
        }
                // now delete
        for ar in skpARs do
        {  NameUser = (string key skpARs)
           unsetDef(mod, ar, NameUser)
        }
        delete(skpARs)
o  OK.  Specific Access, I have the only access rec.  Now add the ones I want
        For every desired access rec
        {  NameUser = desired Group Name
           Permission ps = desired Permission
           setDef(mod, ad, ps, NameUser)
        }
o  Delete the AR associated with me
        unsetDef(mod, ar, doorsname())


Good luck.

 

 

  • Louie

 

 

A few notes of the code:

o  Remove all the others.  Stage in a Skip, then delete
    AccessRec ar
        Skip skpARs = createString()
        for ar in ad do
        {  NameUser = username(ar)
           if (NameUser == doorsname()) continue   // Its me, don't delete
->         if ( null(NameUser) ) continue // Its default user (Everyone else), dont delete
           put(skpARs, NameUser, ar)
        }
                // now delete
        for ar in skpARs do
        {  NameUser = (string key skpARs)
->      //unsetDef(mod, ar, NameUser) // wrong type for second argument
->           unsetDef(mod, ad, NameUser) // We are unsetting attr def 'ad' for user 'NameUser'
        }
->      setDef(mod, ad, "", ?) // Set default user to something
        delete(skpARs)


/Anders

Re: Changing Atttribute access rights
Peterb4134 - Wed Jul 07 08:58:50 EDT 2010

I must apologise for not having already responded to the replies that were posted. My priorities got changed and have only recently got back to looking at this issue.

I did managed to get my heath robinson code to work as the problem was in trying the delete access record 0 which must be some DOORS protected record which I guess is "Everyone else" (I was setting the array size just hadn't included it in the code I originally pasted in. I'm not familiar with skip lists but it looks like something to investigate as seem easier to use than arrays. I've copied the working code below which shows that the suggestions I received would have been better!
Thanks once again to those who responded.

//find number of permissions set to establish required size of array
int j = 0
for ar in values ad do {
j++
}
//create array of users with defined permissions
string sVRSGroups[j]
j=0
for ar in values ad do {
sVRSGroups[j] = (username ar)
j++
}

//clear permissions for all except CEO and DOORS Administrators

for (j=1; j < sizeof sVRSGroups; j++) { //necessary to start j=1 as 0 throws up an error as can not delete default everyone access

if ((sVRSGroups[j] != "CEO") and (sVRSGroups[j] != "DOORS Administrators")) {
ErrMess unsetVal(m, ad, sVRSGroups[j])
}
}